package com.sky.com.sky.mapper;


import com.sky.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;

@Mapper
public interface UserMapper {
    /**
     * 根据openid查询用户信息
     * @param openid
     * @return
     */
    @Select("select * from user where openid=#{openid}")
    User getByOpenid(String openid);


    /**
     * 插入数据
     * @param user
     */
    void insert(User user);

    // 根据用户id查询
    @Select("select * from user where id =#{userId}")
    User getById(Long userId);


    // 统计当天注册用户
    @Select("select count(*) from user where date(create_time) =#{currentDate}")
    Integer countUser(LocalDate currentDate);

    @Select("select count(*) from user where date(create_time) between #{begin} and #{end}")
    Integer getNewUserCount1(LocalDate begin,LocalDate end);
}
